<?php
/**
 * Created by PhpStorm.
 * User: 70791
 * Date: 2020/7/27
 * Time: 19:41
 */

namespace App\HttpController\Api;


use EasySwoole\Component\Di;
use priestll\easyswoole\http\Auth;

class User extends Auth
{
    /**
     * @Di(key="USER_BIZ")
     */
    protected $biz;

    /**
     * @Api(name="updateInfo",group="/api/user",description="更改个人信息",path="/api/user/updateInfo")
     * @ApiAuth(name="authorization",type=string,from={'HEADER'},description="token")
     * @Method(allow={GET})
     * @ResponseParam(name="code",description="状态码")
     * @ResponseParam(name="result",description="api请求结果")
     * @ResponseParam(name="msg",description="api提示信息")
     * @ApiSuccess({"code":200,"result":[],"msg":"SUCCESS"})
     * @ApiFail({"code":400,"result":[],"msg":"FAIL"})
     * @Param(name="name",alias="用户真实名称",required="",string="")
     * @Param(name="mobile",alias="手机号码",required="",lengthMax="11",'')
     */
    public function updateInfo()
    {

        $param = $this->request()->getRequestParam();

        $user = $this->getUser();
        $res = Di::getInstance()->get('USER_BIZ')->update($user['id'], $param['mobile'],$param['name']);

        if ($res['status']) {
            return $this->success($res['data']);
        } else {
            return $this->fail($res['data']);
        }
    }
}